package com.pig.server;

import com.pig.api.User;
import com.pig.api.UserService;
import com.pig.rpc.config.RpcServiceConfig;
import com.pig.rpc.proxy.RpcClientProxy;
import com.pig.rpc.transmission.RpcServer;
import com.pig.rpc.transmission.socket.server.SocketRpcServer;
import com.pig.server.service.UserServiceImpl;

public class Main {

    public static void main(String[] args) {
        //发布UserServiceImpl，获取config
        RpcServiceConfig config = new RpcServiceConfig(new UserServiceImpl());

        RpcServer rpcServer = new SocketRpcServer(8888);
        //发布出去，一旦调用了publishService，就用ServiceProvider做了一个publish
        rpcServer.publishService(config);
        //发布之后再启动
        rpcServer.start();



        //第二节
//        UserServiceImpl userServiceImpl = new UserServiceImpl();
//
//        RpcServiceConfig rpcServiceConfig = new RpcServiceConfig("1.0.0" ,"common",userServiceImpl);
//        System.out.println(rpcServiceConfig.rpcServiceNames());

        //第七节 动态代理实现请求发送
//        RpcClientProxy rpcClientProxy = new RpcClientProxy(new UserServiceImpl());
//        UserService userService = rpcClientProxy.getProxy();
//        User user = userService.getUser(1L);
//        System.out.println(user);



    }
}

